﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Licenta_Stomatologie.Panels
{
    public partial class ReceiptPanel : UserControl
    {
        public ReceiptPanel()
        {
            InitializeComponent();
            getPacients();
        }

        private void getPacients()
        {
            ProjectDBEntities db = new ProjectDBEntities();

            IEnumerable<Pacient> pacients = db.Pacients.Where(p => p.id > 0);

            //cboxPacient.DisplayMember = "Name";
            //cboxPacient.ValueMember = "Id";

            Dictionary<int, String> dict = new Dictionary<int, string>();

            foreach (Pacient pac in pacients)
            {
                dict.Add(pac.id, pac.nume + " " + pac.prenume);      
            }

            cboxPacient.DataSource = new BindingSource(dict, null);

            cboxPacient.DisplayMember = "Value";
            cboxPacient.ValueMember = "Key";
        }

        private void btnGenerate_Click(object sender, EventArgs e)
        {
            Helpers.PDFGenerator gen = new Helpers.PDFGenerator();

            gen.generateReceipt(new String[] { tboxNumeDoctor.Text, cboxPacient.SelectedValue.ToString(), cboxAfectiune.SelectedText, cboxTratament.Text});
        }
    }
}
